<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../style.css" type="text/css" media="screen">
<link rel="stylesheet" href="../../../../print.css" type="text/css" media="print">
<meta content="DynaShape,idv.cjcat.display.dynashape.DynaShape,add,clear,remove,render" name="keywords">
<title>idv.cjcat.display.dynashape.DynaShape</title>
</head>
<body>
<script type="text/javascript" language="javascript" src="../../../../asdoc.js"></script><script type="text/javascript" language="javascript" src="../../../../cookies.js"></script><script type="text/javascript" language="javascript">
<!--
				asdocTitle = 'DynaShape - API Documentation';
				var baseRef = '../../../../';
				window.onload = configPage;
			--></script>
<table style="display:none" id="titleTable" cellspacing="0" cellpadding="0" class="titleTable">
<tr>
<td align="left" class="titleTableTitle">CJLibrary</td><td align="right" class="titleTableTopNav"><a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../package-summary.html">All&nbsp;Packages</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../all-classes.html')" href="../../../../class-summary.html">All&nbsp;Classes</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../../index-list.html')" href="../../../../all-index-A.html">Index</a>&nbsp;|&nbsp;<a href="../../../../index.html?idv/cjcat/display/dynashape/DynaShape.html&amp;idv/cjcat/display/dynashape/class-list.html" id="framesLink1">Frames</a><a onclick="parent.location=document.location" href="" style="display:none" id="noFramesLink1">No&nbsp;Frames</a></td><td rowspan="3" align="right" class="titleTableLogo"><img alt="Adobe Logo" title="Adobe Logo" class="logoImage" src="../../../../images/logo.jpg"></td>
</tr>
<tr class="titleTableRow2">
<td align="left" id="subTitle" class="titleTableSubTitle">Class&nbsp;DynaShape</td><td align="right" id="subNav" class="titleTableSubNav"><a href="#methodSummary">Methods</a></td>
</tr>
<tr class="titleTableRow3">
<td colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("Class DynaShape"); titleBar_setSubNav(false,false,false,false,false,false,true,false,false,false,false,false,false,false);}
--></script>
<div class="MainContent">
<table cellspacing="0" cellpadding="0" class="classHeaderTable">
<tr>
<td class="classHeaderTableLabel">Package</td><td><a onclick="javascript:loadClassListFrame('class-list.html')" href="package-detail.html">idv.cjcat.display.dynashape</a></td>
</tr>
<tr>
<td class="classHeaderTableLabel">Class</td><td class="classSignature">public class DynaShape</td>
</tr>
<tr>
<td class="classHeaderTableLabel">Inheritance</td><td class="inheritanceList">DynaShape <img class="inheritArrow" alt="Inheritance" title="Inheritance" src="../../../../images/inherit-arrow.gif"> flash.display.Sprite</td>
</tr>
<tr>
<td class="classHeaderTableLabel">Implements</td><td><a href="../IRenderable.html">IRenderable</a></td>
</tr>
</table>
<p></p>
  A <code>DynaShape</code> object executes commands stored in <code>DynaGraphics</code> objects it contains.
  <p>
  You can regard a <code>DynaGraphics</code> object as a series of stored drawing commands.
  Upon each call of <code>DynaShape.render()</code>,
  these drawing commands are executed.
  </p>
  <p>
  What this rendering is different from the original Flash drawing API is that,
  a <code>DynaGraphics</code> object only holds references to target objects;
  not until a render call would the coordinate values of these target objects be fectched.
  So if these objects' coordinates are changed through time,
  each render call would redraw the graphics according to these new coordinates.
  </p>
  
  <p></p>
<br>
<span class="label">Example</span>
<br>  <div class='listing'><pre>
  //This example creates a morphing star shape with black line and orange fill.
  
  import flash.events.Event;
  import flash.utils.getTimer;
  import idv.cjcat.display.LineStyle;
  import idv.cjcat.display.Fill;
  import idv.cjcat.display.dynashape.DynaShape;
  import idv.cjcat.display.dynashape.DynaGraphics;
  import idv.cjcat.geom.Vector2;
  
  //create dynamic shape
  var ds:DynaShape = new DynaShape();
  ds.x = ds.y = 200;
  var vectors:Array = new Array();
  var vec:Vector2=new Vector2(0,100);
  var i:int;
  for (i = 0; i &lt; 10; i++) {
   vectors.push(new Vector2());
  }
  
  //connects back to the first point
  vectors.push(vectors[0]);
  for (i = 0; i &lt; vectors.length; i++) {
   vectors[i] = vec.rotate(2 &#42; Math.PI / (vectors.length - 1) &#42; i);
  }
  
  //define styles
  var blackLine:LineStyle=new LineStyle(3,0x000000);
  var orangeFill:Fill=new Fill(0xFFcc00, 1);
  
  //create DynaGraphics
  var star:DynaGraphics = new DynaGraphics();
  
  //set line style and fill
  star.lineStyle(blackLine);
  star.beginFill(orangeFill);
  
  //line through and end fill
  star.moveTo(vectors[0]);
  star.lineThrough(vectors);
  star.endFill();
  
  //add DynaGraphics
  ds.add(star);
  addChild(ds);
  
  //main loop
  addEventListener(Event.ENTER_FRAME, update);
  function update(e:Event):void {
   for (i = 0; i &lt; vectors.length; i++) {
    if (i%2==0) {
     vectors[i].length=100 + 60 &#42; Math.cos(getTimer() / 200);
    } else {
     vectors[i].length=100 + 60 &#42; Math.sin(getTimer() / 200);
    }
   }
  
   //render shape
   ds.render();
  }</pre></div>
  <p></p>
<br>
<hr>
</div>
<a name="methodSummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Methods</div>
<table id="summaryTableMethod" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#DynaShape()">DynaShape</a>(initGraphics:Vector = null)</div>
<div class="summaryTableDescription">
   Creates a dynamic shape.</div>
</td><td class="summaryTableOwnerCol">DynaShape</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#add()">add</a>(dynaGraphics:<a href="DynaGraphics.html">DynaGraphics</a>):void</div>
<div class="summaryTableDescription">
   Addes a <code>DynaGraphics</code> object to the dynamic shape.</div>
</td><td class="summaryTableOwnerCol">DynaShape</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#clear()">clear</a>():void</div>
<div class="summaryTableDescription">
   Clears all graphics.</div>
</td><td class="summaryTableOwnerCol">DynaShape</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#remove()">remove</a>(dynaGraphics:<a href="DynaGraphics.html">DynaGraphics</a>):void</div>
<div class="summaryTableDescription">
   Removes a <code>DynaGraphics</code> object from the dynamic shape.</div>
</td><td class="summaryTableOwnerCol">DynaShape</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#render()">render</a>(e:Event = null):void</div>
<div class="summaryTableDescription">
   Renders the dynamic shape.</div>
</td><td class="summaryTableOwnerCol">DynaShape</td>
</tr>
</table>
</div>
<script type="text/javascript" language="javascript">
<!--
showHideInherited();
--></script>
<div class="MainContent">
<a name="constructorDetail"></a>
<div class="detailSectionHeader">Constructor detail</div>
<a name="DynaShape()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">DynaShape</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">constructor</td>
</tr>
</table>
<div class="detailBody">
<code>public function DynaShape(initGraphics:Vector = null)</code><p>
   Creates a dynamic shape.
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">initGraphics</span>:Vector</code> (default = <code>null</code>)<code></code> &mdash;  A vector of initial paths.
   </td>
</tr>
</table>
</div>
<a name="methodDetail"></a>
<div class="detailSectionHeader">Method detail</div>
<a name="add()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">add</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td>
</tr>
</table>
<div class="detailBody">
<code>public function add(dynaGraphics:<a href="DynaGraphics.html">DynaGraphics</a>):void</code><p>
   Addes a <code>DynaGraphics</code> object to the dynamic shape.
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">dynaGraphics</span>:<a href="DynaGraphics.html">DynaGraphics</a></code> &mdash;  The <code>DynaGraphics</code> object.
   </td>
</tr>
</table>
</div>
<a name="clear()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">clear</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function clear():void</code><p>
   Clears all graphics.
   </p></div>
<a name="remove()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">remove</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function remove(dynaGraphics:<a href="DynaGraphics.html">DynaGraphics</a>):void</code><p>
   Removes a <code>DynaGraphics</code> object from the dynamic shape.
   </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">dynaGraphics</span>:<a href="DynaGraphics.html">DynaGraphics</a></code> &mdash;  The <code>DynaGraphics</code> object.
   </td>
</tr>
</table>
</div>
<a name="render()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">render</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public function render(e:Event = null):void</code><p>
   Renders the dynamic shape. This method can be passed as an event listener.
   </p><p>This method can be used as an event listener.</p>
   <span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">e</span>:Event</code> (default = <code>null</code>)<code></code></td>
</tr>
</table>
</div>
<br>
<br>
<hr>
<br>
<p></p>
<center class="copyright"> 
</center>
</div>
</body>
</html>
<!-- -->
